package com.doit.demo01;

import src.com.doit.Demo04.A;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class test {
    public static void main(String[] args) {
        Home h = new Home();
        h.eatAtHome(new Cat());
        h.eatAtHome(new Dog());
        new Dog().JiDu();

        //多态
        Animal dog = new Dog();
        dog.eat();
        Dog dog2 = (Dog)dog;
        dog2.JiDu();

        //判断是否是同一类型
        if (dog instanceof Dog){
            System.out.println("是");
        }
        List<Animal>list = new ArrayList<>();
        list.add(new Dog());
        list.add(new Cat());
        show(list);
    }
    //泛型写法
    public static void show(List<?extends Animal> list){
        for (Object o : list) {
            Animal a =(Animal)o;
            a.eat();
        }
    }
}
